package o;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.BitmapFactory.Options;
import android.graphics.Matrix;
import android.text.TextUtils;

public class bad {
    private static bad ˋ;

    public static class e {
        private int ˊ = 540;
        private int ˋ = -1;
        private boolean ˎ = false;
        private int ˏ = 960;
        private int ॱ = -1;

        public boolean equals(Object obj) {
            if (this == obj) {
                return true;
            }
            if (obj instanceof e) {
                e eVar = (e) obj;
                if (this.ˋ == eVar.ˋ && this.ॱ == eVar.ॱ && this.ˎ == eVar.ˎ) {
                    return true;
                }
            }
            return false;
        }

        public int hashCode() {
            return 1;
        }
    }

    private bad() {
    }

    public static synchronized bad ˋ() {
        bad o_bad;
        synchronized (bad.class) {
            if (ˋ == null) {
                ˋ = new bad();
            }
            o_bad = ˋ;
        }
        return o_bad;
    }

    private Options ˎ(e eVar, String str) {
        if (eVar == null || TextUtils.isEmpty(str)) {
            azh.ˏ.ˊ("LocalImageLoader", "getOptions, imageInfo == " + eVar + ", imagePath = " + str);
            return null;
        }
        Options options = new Options();
        options.inJustDecodeBounds = true;
        BitmapFactory.decodeFile(str, options);
        float ॱ = ॱ(options.outWidth, options.outHeight, eVar);
        if (ॱ > 3.0f) {
            ॱ += 1.0f;
        }
        options.inSampleSize = (int) ॱ;
        options.inJustDecodeBounds = false;
        return options;
    }

    private float ॱ(int i, int i2, e eVar) {
        int ॱ;
        if (i2 >= i) {
            int i3 = i;
            i = i2;
            i2 = i3;
        }
        int ˎ = eVar.ˏ;
        int ˋ = eVar.ˊ;
        if (eVar.ॱ > 0 && eVar.ˋ > 0) {
            ˎ = eVar.ˋ;
            ˋ = eVar.ॱ;
            if (eVar.ॱ > eVar.ˋ) {
                ॱ = eVar.ॱ;
                ˎ = eVar.ˋ;
                if (i > ॱ && i2 <= ˎ) {
                    return 1.0f;
                }
                if (((double) Math.abs((((float) i) / ((float) i2)) - (((float) ॱ) / ((float) ˎ)))) < 1.0E-6d) {
                    return ((float) i) / ((float) ॱ);
                }
                return ((float) i2) / ((float) ˎ);
            }
        }
        ॱ = ˎ;
        ˎ = ˋ;
        if (i > ॱ) {
        }
        if (((double) Math.abs((((float) i) / ((float) i2)) - (((float) ॱ) / ((float) ˎ)))) < 1.0E-6d) {
            return ((float) i2) / ((float) ˎ);
        }
        return ((float) i) / ((float) ॱ);
    }

    public Bitmap ˊ(e eVar, String str) {
        Options ˎ = ˎ(eVar, str);
        if (ˎ == null) {
            azh.ˏ.ˊ("LocalImageLoader", "getBitmap, options == null");
            return null;
        }
        Bitmap decodeFile = BitmapFactory.decodeFile(str, ˎ);
        if (decodeFile == null) {
            azh.ˏ.ˊ("LocalImageLoader", "getBitmp, bitmap null");
            return null;
        }
        int height = decodeFile.getHeight();
        int width = decodeFile.getWidth();
        float ॱ = ॱ(width, height, eVar);
        if (ॱ <= 1.0f) {
            return decodeFile;
        }
        ॱ = 1.0f / ॱ;
        Matrix matrix = new Matrix();
        matrix.postScale(ॱ, ॱ);
        return Bitmap.createBitmap(decodeFile, 0, 0, width, height, matrix, true);
    }
}
